package users

import (
	"api/internal/respons"
	"api/internal/svc"
	"api/internal/types"
	"context"
	"go.uber.org/zap"
	"smart-health-platforms/pkg"
	"user_srv/user"

	"github.com/zeromicro/go-zero/core/logx"
)

type AddFaseLogic struct {
	logx.Logger
	ctx    context.Context
	svcCtx *svc.ServiceContext
}

func NewAddFaseLogic(ctx context.Context, svcCtx *svc.ServiceContext) *AddFaseLogic {
	return &AddFaseLogic{
		Logger: logx.WithContext(ctx),
		ctx:    ctx,
		svcCtx: svcCtx,
	}
}

func (l *AddFaseLogic) AddFase(req *types.AddFaseRequest) (resp *types.Response, err error) {
	fase, err := l.svcCtx.UserRpc.AddFase(l.ctx, &user.AddFaseRequest{
		Image:  req.Image,
		UserId: req.UserId,
	})
	if err != nil {
		pkg.Error("添加失败", zap.Error(err))
		return nil, err
	}
	return respons.Success(fase), nil
}
